<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="db.UserDAO"%>
<%@page import="db.User"%>
<%@page import="org.json.JSONObject"%>
<%@page import="db.AuthorityDAO"%>
<%@ include file="/jsp/common/utility/volti.jsp" %>
<%
	
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setDateHeader("Expires", 0);
	response.setContentType("application/x-javascript");
	out.clear();
	//System.out.println("===========");
	String callback = request.getParameter("callback");
	String jsonString = request.getParameter("jsonString");
	JSONObject requestJSONobject = new JSONObject(jsonString);
	JSONObject responseJSONObject = new JSONObject();
	
	request.setCharacterEncoding("utf-8");
	
	int id = 0;
	id = requestJSONobject.optInt("userid");
	System.out.println("=======================>"+id);
	WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
	UserDAO userDao = (UserDAO)ctx.getBean("UserDAO");
	AuthorityDAO authorityDAO =(AuthorityDAO)ctx.getBean("AuthorityDAO");
	
	
	
	User user = new User();
	user = userDao.findById(id);
	userDao.delete(user);
	List list1 = authorityDAO.findByUserId(id);
	authorityDAO.deleteByList(list1);
	
	//删除权限表
	String name = request.getParameter("uname");
		responseJSONObject.put("success", true);
		responseJSONObject.put("message", "您的删除操作已成功!");
		String result = callback + "('" + responseJSONObject.toString() + "');";
		out.write(result);
		//return;
	
	
		
%>
